package com.example.demo_debezium_pgsql.util;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

public enum DBOperationEnum {
    CREATE("c"),
    UPDATE("u"),
    READ("r"),
    DELETE("d")
    ;
    private String code;

    DBOperationEnum(String code) {
        this.code = code;
    }

    @JsonValue
    public String getCode() {
        return code;
    }

    @JsonCreator
    public DBOperationEnum createByCode(String code){
        for (DBOperationEnum value : values()) {
            if(value.code.equals(code)){
                return value;
            }
        }
        return null;
    }
}
